FROM golang:1.18-alpine AS builder
ENV GO111MODULE=on
ENV CGO_ENABLE=1
ENV GOOS=linux
ENV GOARCH=amd64
ENV GOPROXY=https://goproxy.cn,direct
WORKDIR /build

COPY . .
RUN apk add --no-cache gcc g++ libc-dev
RUN go mod download && go build -o jetbra .

FROM alpine
WORKDIR /app
COPY --from=builder /build/jetbra /app/
COPY . .
RUN chmod +x /app/jetbra
EXPOSE 8080

ENTRYPOINT [ "/app/jetbra" ]